<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // JS中this指向
    const obj = {
      name: 'zs',
      sayHello() {
        // 普通函数中, 谁调用指向谁
        // 如果没有调用者, web中指向window
        console.log('this  ----->  ', this);
      },

      sayHi: () => {
        console.log('this  ----->  ', this);
      }
    }

    obj.sayHello()//  obj

    // 💥箭头函数本身没有this, 自动绑定调用时所处的环境中的this
    obj.sayHi() // window

    function hello() {
      console.log('this  ----->  ', this);
    }

    hello() // window
    // hello() 等价于 window.hello()


  </script>
</body>

</html>